package com.osdp.startup;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;

/**
 * 认证服务器（分布式认证，采用OAuth2)
 * OAuth2.0分为认证授权中心、资源服务。认证中心用于颁发令牌，资源服务解析令牌并且提供资源
 *
 * https://howtodoinjava.com/spring-boot2/h2-database-example/
 * https://www.cnblogs.com/cjsblog/p/12425912.html
 *
 * java -jar target/micro-auth-app-0.0.1-SNAPSHOT.jar --server.port=8082
 * EnableDiscoveryClient 能够让注册中心能够发现,扫描到该服务
 *
 * @author liubo
 *
 */
@SpringBootApplication(scanBasePackages = "com.osdp")
@MapperScan("com.osdp.*.mapper")
@EnableFeignClients(basePackages="com.osdp.*.feign")
@ComponentScan(basePackages = {"com.osdp"})
@EnableDiscoveryClient
public class MicroAuthApplication {
	
	public static void main(String[] args) {
		SpringApplication.run(MicroAuthApplication.class, args);
	}

	@Bean
	@LoadBalanced
	public RestTemplate restTemplate(){
		return new RestTemplate();
	}
}
